<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head >
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/vue/vue.js"></script>
</head>
<body>
<!--v-bind属性绑定--->
<div id="app">

    <ul>    <!--  方式1： 三元运算显示男女 -->
        <li v-for="e in emps" v-on:click="clickMe($event, e)">{{e.id}}--{{e.name}}--{{e.age}}--{{e.sex == 1 ? '男' : '女'}}</li>
    </ul>
    <ul>    <!--  方式2：过滤器 -->
        <li v-for="e in emps" v-on:click="clickMe($event, e)">{{e.id}}--{{e.name}}--{{e.age}}--{{e.sex | sexFilter}}</li>
    </ul>

</div>
<script>
    var vue = new Vue({
        el:"#app",
        data:{
            arr: ["a", "b", "c", "d"],
            emps:[
                {id:1, name:"dafei", age:18, sex:1},
                {id:2, name:"xiaofei", age:17, sex:1},
                {id:3, name:"xiaobin", age:16, sex:0},
                {id:4, name:"yanglong", age:10, sex:-1}
            ]
        },
        methods : {
            clickMe: function(event, e) {
                console.log(event);
                console.log(event.target);
                console.log(e);
                console.log(e.id + '-' + e.name + '-' + e.age);
                console.log(11);
            }
        },
        filters : {
            sexFilter: function(sex) {
                if (sex == 1){
                    return '男'
                }else if (sex == 0) {
                    return '女'
                }else {
                    return '保密'
                }
            }
        },
        mounted: function() {
            console.log("初始化")
        },
    })
</script>
</body>
</html>